import { computed, onMounted, ref } from "vue";
import {
  getChartsInfoApi,
} from "@/api/system/dashboard";
import GroupLine from "@iconify-icons/ri/group-line";
import LogLine from "@iconify-icons/ep/tickets";
import { getKeyList } from "@pureadmin/utils";
import * as echarts from "echarts";
import { useECharts } from "@pureadmin/utils";

export function useDashboard() {

	const loading = ref(true);
	const chartData = ref([]);
	// const triggerCountFailTotal = 0;
	// const triggerDayList = [];
	// const triggerDayCountRunningList = [];
	// const triggerDayCountSucList = [0];

	const getChartsInfo = () => {
		getChartsInfoApi({ "startDate": "", "endDate": "" }).then(res => {
			console.log(res);
			if (res.code === 200) {
				const triggerCountFailTotal = res.content.triggerCountFailTotal;
				const triggerCountRunningTotal = res.content.triggerCountRunningTotal;
				const triggerCountSucTotal = res.content.triggerCountSucTotal;
				const triggerDayList = res.content.triggerDayList;
				const triggerDayCountRunningList = res.content.triggerDayCountRunningList;
				const triggerDayCountFailList = res.content.triggerDayCountFailList;
				const triggerDayCountSucList = res.content.triggerDayCountSucList;
				chartData.value.push({
					icon: GroupLine,
					bgColor: "#eff8f4",
					color: "#26ce83",
					duration: 2200,
					name: "任务数量",
					// value: triggerCountFailTotal,
					value: 100,
					percent: "触发的调度次数",
					data: [10, 10, 10]
				});
				chartData.value.push({
					icon: GroupLine,
					bgColor: "#eff8f4",
					color: "#26ce83",
					duration: 2200,
					name: "调度次数",
					value: triggerCountRunningTotal,
					percent: "触发的调度次数",
					data: ""
				});
				chartData.value.push({
					icon: LogLine,
					bgColor: "#eff8f4",
					color: "#26ce83",
					duration: 2200,
					name: "执行器数量",
					value: triggerCountSucTotal,
					percent: "在线的执行器机器数量",
					data: ""
				});


			}
		}
	)
	};

  onMounted(() => {
    getChartsInfo();

  });
		
   return {
      loading: loading,
      chartData: chartData,
	// triggerDayList:triggerDayList 
   };
		
}

